package com.tron.dobest.mybatisplus.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tron.dobest.common.BaseController;
import com.tron.dobest.mybatisplus.entity.User;
import com.tron.dobest.mybatisplus.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.Arrays;
import java.util.List;

/**
 * 描述：
 *
 * @author TRON
 * @since 2020-03-24
 */
@RestController
@Transactional
@Validated
public class UserController extends BaseController {


    @Autowired
    UserServiceImpl userService;

    @GetMapping("/getUser")
    public FinalResult<String> getUser(@Validated @NotBlank(message = "id不能为空") String name){
        userService.list(Wrappers.<User>lambdaQuery().likeLeft(User::getName, name).gt(User::getAge,30));
        return buildFinalResult("user");
    }

    @GetMapping("/testGet")
    public Object getTest() {
        List<String> a = Arrays.asList("a");
        return a;
    }
}
